package org.example.work2.tcc.order.service;


import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * 订单服务
 *
 * @author xh
 * @date 2023/04/03
 */
@LocalTCC
public interface OrderAction {


//    /**
//     * 创建订单
//     *
//     * @param order 订单
//     * @return boolean
//     * @throws Exception 异常
//     */
//    boolean createOrder(Order order) throws Exception;


    @TwoPhaseBusinessAction(name = "orderAction", commitMethod = "createOrderCommit", rollbackMethod = "createOrderRollBack")
    boolean createOrderPrepare(BusinessActionContext actionContext,
                               @BusinessActionContextParameter("id") Long id,
                               @BusinessActionContextParameter("accountCode") String accountCode,
                               @BusinessActionContextParameter("productId") String productId,
                               @BusinessActionContextParameter("productCounts") Integer productCounts,
                               @BusinessActionContextParameter("totalPrice") Integer totalPrice) throws Exception;

    boolean createOrderCommit(BusinessActionContext actionContext) throws Exception;

    boolean createOrderRollBack(BusinessActionContext actionContext) throws Exception;
}
